package com.lxd.mybatisplus.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lxd.mybatisplus.entity.User;
import com.lxd.mybatisplus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuxiaoding
 * @Date 2019/11/20
 **/
@RestController
@RequestMapping(value="user")
public class UserComplexController {
    @Autowired
    private UserService userService;

    /**
     * 模糊查询+大于+小于+分页
     * @param keyWord
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "likePage")
    public Object likePage(String keyWord,Long page,Long pageSize){
        QueryWrapper<User> userQueryWrapper=new QueryWrapper<User>();
        Page<User> pageInfo=new Page<>(page==null?1L:page,pageSize==null?5L:pageSize);
        userQueryWrapper.like("name",keyWord);
        userQueryWrapper.gt("id",2);

        return userService.page(pageInfo,userQueryWrapper);
    }
}
